home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / ABox.v1.8 / CPlus Files / ABTopic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  17.7 KB  |  851 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABTopic.c
  15.  
  16. NAME
  17.     ABTopic.c, part of the ABox project source code,
  18.     responsible for handling the AboutBox Topic class stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                netromancr@aol.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <netromancr@aol.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     9 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     28-july-94    -    ty    -    1.0.6 -- removed cursor code to mix-in class
  38.                                 ABUCursor; removed cursor flipping from Load
  39.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  40.                             release and the associated Universal Headers from Apple:
  41.                             most methods that returned references now have "Ref" at
  42.                             the end of their methods names to prevent possible collisions
  43.                             with datatypes and classes of the same name (older versions
  44.                             of the compiler didn't have a problem with this).
  45. */
  46.  
  47. /*===========================================================================*/
  48.  
  49. /*======= Segmentation directives ========*/
  50.  
  51. #ifdef USE_MANUAL_SEGMENTATION
  52. #pragma segment ty
  53. #endif
  54.  
  55. /*============ Header files ==============*/
  56.     
  57. #include     "ABTopic.h"
  58. #include    "ABoxDefs.h"
  59. #include    "ABSlide.h"
  60.  
  61.  
  62. #include    "ABPict.h"
  63. #include    "ABText.h"
  64. #include    "ABStr.h"
  65. #include    "ABSound.h"
  66.  
  67. #include    "ABUCursor.h"
  68.  
  69. /*=============== Globals ================*/
  70.  
  71. /*================ CODE ==================*/
  72.  
  73.  
  74. /*=============================== ABTopic::ABTopic ================================*/
  75. ABTopic::ABTopic(void)
  76. {
  77.     this->InitializeTopic();
  78. } // end ABTopic
  79.  
  80.  
  81.  
  82. /*=============================== ABTopic::ABTopic ================================*/
  83. ABTopic::ABTopic(const FSSpec& inTopicFSSpec)
  84. {
  85.     this->InitializeTopic();
  86.     (void)this->CheckAndCopyFSSpec(inTopicFSSpec);
  87. } // end ABTopic
  88.  
  89.  
  90.  
  91. /*=============================== ABTopic::InitializeTopic ================================*/
  92. void
  93. ABTopic::InitializeTopic(void)
  94. {
  95.     this->SlidesRef() = new ABLinkedList;
  96.     this->FSSpecPointerRef() = NULL;
  97.     this->NameRef() = (StringPtr)::NewPtrClear (kABTopicNameSize);
  98.     this->FileRefNumRef() = kABBadTopicFileRefNum;
  99.     this->TopicType() = ETopicType_Topic;
  100. } // end InitializeTopic
  101.  
  102.  
  103.  
  104. /*=============================== ABTopic::~ABTopic ================================*/
  105. ABTopic::~ABTopic(void)
  106. {
  107.     (void)this->CloseTopicFile();
  108.  
  109.     if (this->HasFSSpecPointer())
  110.     {
  111.         ::DisposPtr ((Ptr)this->FSSpecPointerRef());
  112.         this->FSSpecPointerRef() = NULL;
  113.     }
  114.     
  115.     if (this->HasNameRef())
  116.     {
  117.         ::DisposPtr ((Ptr)this->NameRef());
  118.         this->NameRef() = NULL;
  119.     }
  120.     
  121.     this->ResetSlideInfo();
  122.     
  123. } // end ~ABTopic
  124.  
  125.  
  126.  
  127. /*=============================== ABTopic::ResetSlideInfo ================================*/
  128. void
  129. ABTopic::ResetSlideInfo(void)
  130. {
  131.     if (this->HasSlides())
  132.     {
  133.         delete this->SlidesRef();
  134.         this->SlidesRef() = NULL;
  135.     }
  136.     
  137. } // end ResetSlideInfo
  138.  
  139.  
  140.  
  141. /*=============================== ABTopic::ResetFileInfo ================================*/
  142. void
  143. ABTopic::ResetFileInfo(void)
  144. {
  145.     this->ResetFSSpecPointer();
  146.     this->ResetFileRefNum();
  147. } // end ResetFileInfo
  148.  
  149.  
  150.  
  151.  
  152. /*=============================== ABTopic::ResetFSSpecPointer ================================*/
  153. void
  154. ABTopic::ResetFSSpecPointer(void)
  155. {
  156.     if (this->HasFSSpecPointer())
  157.     {
  158.         ::DisposPtr ((Ptr)this->FSSpecPointerRef());
  159.         this->FSSpecPointerRef() = NULL;
  160.     }
  161.     
  162. } // end ResetFSSpecPointer
  163.  
  164.  
  165.  
  166. /*=============================== ABTopic::ResetFileRefNum ================================*/
  167. void
  168. ABTopic::ResetFileRefNum(void)
  169. {
  170.     this->FileRefNumRef() = kABBadTopicFileRefNum;
  171.     
  172. } // end ResetFileRefNum
  173.  
  174.  
  175.     
  176.  
  177.  
  178. /*=============================== ABTopic::UseTopicResFile ================================*/
  179. short
  180. ABTopic::UseTopicResFile(void) const
  181. {
  182.     short oldResFile = ::CurResFile();
  183.     
  184.     if (this->HasFileRefNum())
  185.         ::UseResFile(this->GetFileRefNum());
  186.     
  187.     return oldResFile;
  188. } // end UseTopicResFile
  189.  
  190.  
  191.  
  192. /*=============================== ABTopic::ResizeAndDraw ================================*/
  193. OSErr
  194. ABTopic::ResizeAndDraw(Rect& inItemRect, WindowPtr inWindow)
  195. {
  196.     OSErr anError = noErr;
  197.     
  198.     anError = this->Resize(&inItemRect);
  199.     if (anError == noErr)
  200.         anError = this->EraseFrame(inItemRect);
  201.     if (anError == noErr)
  202.         anError = this->Draw(inWindow);
  203.     
  204.     return anError;
  205. } // end ResizeAndDraw
  206.  
  207.  
  208. /*=============================== ABTopic::GetProperty ================================*/
  209. OSErr    ABTopic::GetProperty(ABProperty prop, 
  210.                                 void *ptr, 
  211.                                 long *ptrSize)
  212. {
  213.     OSErr    error = noErr;
  214.     long    pSize;
  215.     
  216.     //    begin here...
  217.     
  218.     if (!ptr)
  219.         return kABPropertyNullStorage;
  220.     
  221.     switch (prop)
  222.     {
  223.         case    kABTopicIndex:
  224.                     *((ABIndex *)ptr) = this->Ordinal();
  225.                     pSize = kABTopicIndexSize;
  226.                     break;
  227.         case    kABTopicNumberOfSlides:
  228.                     if (this->HasSlides())
  229.                         *((ABListCount *)ptr) = this->SlidesRef()->Count();
  230.                     else
  231.                         *((ABListCount *)ptr) = 0;
  232.                     pSize = kABTopicNumberOfSlidesSize;
  233.                     break;
  234.         case    kABTopicFSSpec:
  235.                     if (this->HasFSSpecPointer())
  236.                         *((FSSpecPtr)ptr) = *(this->FSSpecPointerRef());
  237.                     pSize = kABTopicFSSpecSize;
  238.                     break;
  239.         case    kABTopicName:
  240.                     if (this->HasNameRef())
  241.                         ::BlockMove (this->NameRef(), (Ptr)ptr, *(this->NameRef())+1);
  242.                     pSize = kABTopicNameSize;
  243.                     break;
  244.         case    kABTopicDepth:
  245.                     *((long *)ptr) = this->Depth();
  246.                     pSize = kABTopicDepthSize;
  247.                     break;
  248.         case    kABTopicType:
  249.                     *((ETopicType *)ptr) = this->TopicType();
  250.                     pSize = kABTopicTypeSize;
  251.                     break;
  252.         default:
  253.                     error = kABTopicSuperProperties::GetProperty(prop, ptr, ptrSize);
  254.                     break;
  255.     } // end switch block
  256.     
  257.     if (ptrSize && !error)
  258.         *ptrSize = pSize;
  259.     return error;
  260.     
  261. } // end GetProperty
  262.  
  263.  
  264.  
  265. /*=============================== ABTopic::SetProperty ================================*/
  266. OSErr    ABTopic::SetProperty(ABProperty prop, 
  267.                                 void *ptr, 
  268.                                 long ptrSize)
  269. {
  270.     OSErr    error = noErr;
  271.     
  272.     //    begin here...
  273.     
  274.     if (!ptr)
  275.         return kABPropertyNullStorage;
  276.     
  277.     switch (prop)
  278.     {
  279.         case    kABTopicNumberOfSlides:
  280.         case    kABTopicFSSpec:
  281.         case    kABTopicName:
  282.         case    kABTopicDepth:
  283.         case    kABTopicType:
  284.                     error = kABPropertyReadOnly;
  285.                     break;
  286.         default:
  287.                     error = kABTopicSuperProperties::SetProperty(prop, ptr, ptrSize);
  288.                     break;
  289.     } // end switch block
  290.     
  291.     return error;
  292.     
  293. } // end SetProperty
  294.  
  295.  
  296.  
  297.  
  298.  
  299. /*=============================== ABTopic::Draw ================================*/
  300. OSErr    ABTopic::Draw(WindowPtr window)
  301. {
  302.     OSErr    error = noErr;
  303.     
  304.     ABSlide        *slide = NULL;
  305.     short        curResFile = ::CurResFile();
  306.     
  307.     //    begin here...
  308.     //
  309.     short        oldResFile = this->UseTopicResFile();
  310.  
  311.     slide = this->CurrentSlide();
  312.     if (slide)
  313.         error = slide->Draw(window);
  314.     
  315.     ::UseResFile (oldResFile);
  316.     
  317.     return error;
  318.     
  319. } // end Draw
  320.  
  321.  
  322.  
  323. /*=============================== ABTopic::Update ================================*/
  324. OSErr    ABTopic::Update(WindowPtr window)
  325. {
  326.     OSErr    error = noErr;
  327.     
  328.     ABSlide        *slide = NULL;
  329.     
  330.     //    begin here...
  331.     //
  332.     short        oldResFile = this->UseTopicResFile();
  333.         
  334.     slide = this->CurrentSlide();
  335.     if (slide)
  336.         error = slide->Update(window);
  337.         
  338.     ::UseResFile (oldResFile);
  339.     
  340.     return error;
  341.     
  342. } // end Update
  343.  
  344.  
  345.  
  346.  
  347. /*=============================== ABTopic::Event ================================*/
  348. Boolean    ABTopic::Event(EventRecord *eventRec)
  349. {
  350.     Boolean    handled = false;
  351.     
  352.     ABSlide        *slide = NULL;
  353.     
  354.     //    begin here...
  355.     //
  356.     short        oldResFile = this->UseTopicResFile();
  357.         
  358.     slide = this->CurrentSlide();
  359.     if (slide)
  360.         handled = slide->Event(eventRec);
  361.         
  362.     ::UseResFile(oldResFile);
  363.     
  364.     return handled;
  365.  
  366. } // end Event
  367.  
  368.  
  369.  
  370. /*=============================== ABTopic::Stop ================================*/
  371. OSErr    ABTopic::Stop(void)
  372. {
  373.     OSErr        error = noErr;
  374.     ABSlide        *slide = NULL;
  375.     
  376.     //    begin here...
  377.     //
  378.     short        oldResFile = this->UseTopicResFile();
  379.         
  380.     slide = this->CurrentSlide();
  381.     if (slide)
  382.         error = slide->Stop();
  383.     
  384.     ::UseResFile (oldResFile);
  385.     
  386.     return error;
  387.     
  388. } // end Stop
  389.  
  390.  
  391.  
  392.  
  393. /*=============================== ABTopic::NextSlide ================================*/
  394. OSErr    ABTopic::NextSlide(void)
  395. {
  396.     OSErr        error = noErr;
  397.     ABSlide        *slide;
  398.     
  399.     error = this->Stop();
  400.     if (this->HasSlides())
  401.     {
  402.         slide = (ABSlide *)(this->SlidesRef()->NextLink());
  403.     } // end if (slides)
  404.     
  405.     return error;
  406. } // end NextSlide
  407.  
  408.     
  409.         
  410.  
  411. /*=============================== ABTopic::PreviousSlide ================================*/
  412. OSErr    ABTopic::PreviousSlide(void)
  413. {
  414.     OSErr        error = noErr;
  415.     ABSlide        *slide;
  416.     
  417.     error = this->Stop();
  418.     if (this->HasSlides())
  419.     {
  420.         slide = (ABSlide *)(this->SlidesRef()->PreviousLink());
  421.     } // end if (slides)
  422.     
  423.     return error;
  424. } // end PreviousSlide
  425.  
  426.  
  427.  
  428. /*=============================== ABTopic::CurrentSlide ================================*/
  429. ABSlide    *ABTopic::CurrentSlide(void)
  430. {    
  431.     if (this->HasSlides())
  432.     {
  433.         return (ABSlide *)(this->SlidesRef()->GetCurrentLink());
  434.     } else {
  435.         return NULL;
  436.     } // end if (slides)
  437.     
  438. } // end CurrentSlide
  439.  
  440.  
  441.  
  442. /*=============================== ABTopic::GotoSlide ================================*/
  443. OSErr    ABTopic::GotoSlide(long number)
  444. {
  445.     OSErr        error = noErr;
  446.     ABSlide        *slide;
  447.     
  448.     error = this->Stop();
  449.     if (this->HasSlides())
  450.     {
  451.         slide = (ABSlide *)(this->SlidesRef()->GotoLink(number));
  452.         if (!slide)
  453.             error = paramErr;
  454.     } // end if (slides)
  455.     
  456.     return error;
  457. } // end GotoSlide
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464. /*=============================== ABTopic::Resize ===============================*/
  465. //
  466. //    this function will rearrange and resize the picture and the
  467. //    text fields that appear on a slide.
  468. //
  469. //    This method will cause the current slide for the
  470. //    topic to resize by invoking that item's resize method.
  471. //
  472. //    is called by:
  473. //
  474. OSErr    ABTopic::Resize (Rect const *field)
  475. {
  476.     OSErr    error = noErr;
  477.     ABSlide    *currentSlide = NULL;
  478.     
  479.     //    begin here...
  480.     
  481.     if (field == NULL)
  482.         return paramErr;
  483.     
  484.     Rect box = *field;
  485.     error = this->SetProperty(kABObjectRect, &box, kABObjectRectSize);
  486.     if (error != noErr)
  487.         return error;
  488.         
  489.     if (this->HasSlides())
  490.         currentSlide = (ABSlide *) this->SlidesRef()->GetCurrentLink();
  491.     
  492.     if (currentSlide)
  493.         error = currentSlide->Resize(field);
  494.  
  495.     return error;
  496. } // end of Resize
  497.  
  498.  
  499.  
  500.  
  501. /*=============================== ABTopic::CheckAndCopyFSSpec ===============================*/
  502. //
  503. //    This function will copy and/or create an FSSpecPtr
  504. //    from the given parameter.
  505. //
  506. //
  507. OSErr    ABTopic::CheckAndCopyFSSpec (const FSSpec& file)
  508. {
  509.     OSErr            error = noErr;
  510.     
  511.     //    begin here...
  512.  
  513.     //    the caller has specified a topic file to use,
  514.     //    so we'll replace whatever one we might have internally
  515.     //    with this one.
  516.     
  517.     if (this->DoesntHaveFSSpecPointer())
  518.     {
  519.         //    oops! we need to create some storage first...
  520.         this->FSSpecPointerRef() = (FSSpecPtr)::NewPtrClear(kABTopicFSSpecSize);
  521.         error = ::MemError();
  522.         if (error || this->DoesntHaveFSSpecPointer())
  523.         {
  524.             //    yikes! storage failed! mayday!mayday! danger will robinson...
  525.             if (!error)
  526.                 error = memFullErr;
  527.             return error;
  528.         } // end if block
  529.     } // end if block
  530.     
  531.     //    use the one passed as the argument, but save it
  532.     //    into the object's field
  533.     ::BlockMove ((Ptr)&file, (Ptr)this->FSSpecPointerRef(), kABTopicFSSpecSize);
  534.     
  535.     return error;
  536. } // end CheckAndCopyFSSpec()
  537.  
  538.  
  539.  
  540.  
  541.  
  542. /*=============================== ABTopic::OpenTopic ================================*/
  543. OSErr    ABTopic::OpenTopic(void)
  544. {
  545.     OSErr        error = noErr;
  546.  
  547.     //    begin here...
  548.     
  549.     ABUCursor::WatchCursor();
  550.     if (this->HasFSSpecPointer())
  551.     {
  552.         this->FileRefNumRef() = ::FSpOpenResFile (this->FSSpecPointerRef(), fsRdPerm);
  553.         error = ::ResError();
  554.     } // end if block
  555.     
  556.     if (!error && this->HasFileRefNum())
  557.     {
  558.         (void)this->UseTopicResFile();
  559.         error = this->GotoSlide(1);
  560.     } // end if block
  561.     
  562.     ABUCursor::ArrowCursor();
  563.     return error;
  564. } // end OpenTopic
  565.  
  566.  
  567.  
  568.  
  569. /*=============================== ABTopic::CloseTopicFile ================================*/
  570. OSErr    ABTopic::CloseTopicFile(OSErr inError)
  571. {
  572.     OSErr        error = noErr;
  573.  
  574.     //    begin here...
  575.     error = this->CloseTopicFile();
  576.  
  577.     if (inError != noErr)
  578.         this->ResetFileInfo();
  579.         
  580.     return error;
  581. } // end CloseTopicFile
  582.  
  583.  
  584.  
  585. /*=============================== ABTopic::CloseTopicFile ================================*/
  586. OSErr    ABTopic::CloseTopicFile(void)
  587. {
  588.     OSErr        error = noErr;
  589.  
  590.     //    begin here...
  591.     if (this->HasFSSpecPointer() && this->HasFileRefNum())
  592.     {
  593.         ::CloseResFile(this->FileRefNumRef());
  594.         error = ::ResError();
  595.         this->ResetFileRefNum();
  596.     } // end if block
  597.  
  598.     return error;
  599. } // end CloseTopicFile
  600.  
  601.  
  602.  
  603.  
  604. /*=============================== ABTopic::CloseTopic ================================*/
  605. OSErr    ABTopic::CloseTopic(void)
  606. {
  607.     OSErr        error = noErr;
  608.  
  609.     //    begin here...
  610.     
  611.     ABUCursor::WatchCursor();
  612.     error = this->Stop();
  613.  
  614.     if (error == noErr)
  615.         error = this->CloseTopicFile();
  616.  
  617.     ABUCursor::ArrowCursor();
  618.     return error;
  619. } // end CloseTopic
  620.  
  621.  
  622.  
  623.  
  624. /*=============================== ABTopic::Load ===============================*/
  625. //
  626. //
  627. OSErr    ABTopic::Load (short inFileRefToUse)
  628. {
  629.     OSErr            error = noErr;
  630.  
  631.     this->FileRefNumRef() = inFileRefToUse;
  632.     
  633.     error = this->Load();
  634.     return error;
  635.  
  636. } // end of Load
  637.  
  638.  
  639.  
  640.  
  641. /*=============================== ABTopic::Load ===============================*/
  642. //
  643. //
  644. OSErr    ABTopic::Load (void)
  645. {
  646.     OSErr            error = noErr;
  647.  
  648.     short            count = 0;
  649.     short            id = 0;
  650.     Handle            rHandle = NULL;
  651.     Ptr                rPtr = NULL;
  652.     ABSlide            *slide = NULL;
  653.     const short        size = sizeof(short int);
  654.     const short        resourceIndex = 1;
  655.     Boolean            slideCount = false;
  656.     
  657.     //    begin here...
  658.  
  659.     //    if not given an FSSpecPtr, this topic will attempt to grab from the current
  660.     //    resource file.
  661.     if (this->DoesntHaveFSSpecPointer() && this->DoesntHaveFileRefNum())
  662.     {
  663.         //    we don't have a file to look at, or an open resource
  664.         //    file that we should look at, so return
  665.         this->ResetFileInfo();
  666.         error = resNotFound;
  667.     } else {
  668.         slideCount = this->DoCheckSlides();
  669.         if (slideCount < 1)
  670.         {
  671.             //    there wasn't anything of interest...
  672.             //
  673.             error = resNotFound;
  674.         } // end if (error)
  675.     
  676.     } // end if block
  677.     
  678.     if (error == noErr)
  679.         error = this->DoLoad();
  680.     
  681.     this->CloseTopicFile(error);
  682.  
  683.     return error;
  684.  
  685. } // end of Load
  686.  
  687.  
  688.  
  689. /*=============================== ABTopic::DoCheckSlides ===============================*/
  690. //
  691. //    This function checks a file for the presense of a topic/slide definition
  692. //    resource and will an error type (OSErr)
  693. //
  694. //
  695. //    is called by:
  696. //
  697. short    ABTopic::DoCheckSlides (void)
  698. {
  699.     OSErr            error = noErr;
  700.     short            tempRefNum, oldResFile;
  701.     short            count = 0;
  702.     
  703.     //    begin here...
  704.  
  705.     oldResFile = ::CurResFile();
  706.     if (this->HasFSSpecPointer()) 
  707.     {
  708.         //    check the given file...
  709.         
  710.         tempRefNum = ::FSpOpenResFile (this->FSSpecPointerRef(), fsRdPerm);
  711.         error = ::ResError();
  712.         if (error)
  713.         {
  714.             ::UseResFile (oldResFile);
  715.             return count;
  716.         } // end if block
  717.         
  718.     } else if (this->HasFileRefNum()) {
  719.         //    check the preset, pre-opened resource file
  720.         tempRefNum = this->FileRefNumRef();
  721.     } else {
  722.         //    nothing to check, so leave...
  723.         return count = 0;
  724.     } // end if block
  725.     
  726.     ::UseResFile(tempRefNum);
  727.     count = ::Count1Resources (kABTopicSlideResource);
  728.     error = ::ResError();
  729.     
  730.     if (!error && count < 1)
  731.         error = resNotFound;
  732.         
  733.     if (this->HasFSSpecPointer()) 
  734.     {
  735.         ::CloseResFile(tempRefNum);
  736.     } // end if block
  737.                 
  738.     ::UseResFile(oldResFile);
  739.     return count;
  740.     
  741. }    //    end of function DoCheckSlides
  742.  
  743.  
  744. /*=============================== ABTopic::DoLoad ===============================*/
  745. //
  746. //
  747. OSErr    ABTopic::DoLoad (void)
  748. {
  749.     OSErr            error = noErr;
  750.  
  751.     short            count = 0;
  752.     short            id = 0;
  753.     Handle            rHandle = NULL;
  754.     Ptr                rPtr = NULL;
  755.     ABSlide            *slide = NULL;
  756.     short            slideNumber;
  757.     const short        size = sizeof(short int);
  758.     const short        resourceIndex = 1;
  759.     long            index;
  760.     short            oldRefNum;
  761.     Boolean            slideCount = false;
  762.     
  763.     //    begin here...
  764.  
  765.     //    if not given an FSSpecPtr, this topic will attempt to grab from the current
  766.     //    resource file.
  767.     if (this->DoesntHaveFSSpecPointer() && this->DoesntHaveFileRefNum())
  768.     {
  769.         //    we don't have a file to look at, or an open resource
  770.         //    file that we should look at, so return
  771.         this->ResetFileRefNum();
  772.         return resNotFound;
  773.     } // end if block
  774.         
  775.     //    we did find a slide resource, so now get it and
  776.     //    process it.
  777.     oldRefNum = ::CurResFile();
  778.     if (this->HasFSSpecPointer()) 
  779.     {
  780.         //    the caller specified a file to use, so save the
  781.         //    old one and open the new one.
  782.         this->FileRefNumRef() = ::FSpOpenResFile (this->FSSpecPointerRef(), fsRdPerm);
  783.         error = ::ResError();
  784.         if (error) 
  785.         {
  786.             this->ResetFileRefNum();
  787.             ::UseResFile (oldRefNum);
  788.             return error;
  789.         } // end if else block
  790.     } // end if block
  791.     
  792.     //    set the resource file!
  793.     (void)this->UseTopicResFile();
  794.     
  795.     //    get the resource.
  796.     rHandle = ::Get1IndResource (kABTopicSlideResource, resourceIndex);
  797.     error = ::ResError();
  798.     
  799.     if (rHandle && !error && this->HasSlides()) 
  800.     {
  801.         //    we got everything we needed without a problem, so
  802.         //    load the resource into a data structure.
  803.         
  804.         ::HLock (rHandle);
  805.         rPtr = *rHandle;
  806.  
  807.         //    we have the resource, so now load it into a data structure
  808.         //
  809.         //    find out how large the list is:
  810.         ::BlockMove (rPtr, (Ptr)&count, size);
  811.         rPtr += size;
  812.             
  813.         for (index = 1; (index <= count) && rPtr; ++index) 
  814.         {
  815.             //    grab the next item from the resource
  816.             ::BlockMove (rPtr, (Ptr)&(slideNumber), size);
  817.             rPtr += size;
  818.             
  819.             //    create a new slide...
  820.             slide = new ABSlide;
  821.             if (slide)
  822.             {
  823.                 error = slide->SetProperty(kABSlideNumber, &slideNumber, kABSlideNumberSize);
  824.                 this->SlidesRef()->Append(slide);
  825.             } // end if (slide)
  826.             
  827.         }    //    end for(index) loop
  828.         
  829.         ::HUnlock (rHandle);
  830.  
  831.     } // end if block
  832.     
  833.     //    clean up time!
  834.     //
  835.     if (rHandle)
  836.         ::ReleaseResource(rHandle);
  837.     
  838.     ::UseResFile (oldRefNum);
  839.     
  840.     return error;
  841.     
  842. }    //    end of function DoLoad
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849. //    end of file
  850.  
  851.